package com.hmall.search.web;
import com.hmall.common.dto.PageDTO;
import com.hmall.search.pojo.RequestParams;
import com.hmall.search.pojo.itemDoc;
import com.hmall.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("search")
public class SearchController {

    @Autowired(required = false)
    private SearchService searchService;

    //测试
    @GetMapping("/hi")
    public String hi(){
        return "hi";
    }



    /**
     * 酒店搜索自动补全
     */
    @GetMapping("/suggestion")
    public List<String> suggestion(String key){
        return searchService.suggestion(key);
    }


    /**
     * 酒店动态过滤条件,过滤项聚合功能
     * @param params
     * @return  条件集合
     */
    @PostMapping("/filters")
    public Map<String, List<String>> filters(RequestParams params){
        return searchService.filters(params);
    }


    /**
     * 酒店条件搜索  + 分页
     * @param params 前端提供数据
     * @return
     */
    @PostMapping("/list")
    public PageDTO<itemDoc> search(@RequestBody RequestParams params){
        return searchService.search(params);
    }



}
